package resemClass;


import java.io.IOException;
import java.io.PrintWriter;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet(urlPatterns={"/login"})
public class ConfigLogin extends HttpServlet{
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws IOException {
        response.setContentType("text/json; charset=utf-8");
        PrintWriter out = response.getWriter();
        String username = request.getParameter("username");
        String password = request.getParameter("password");

        try{
            boolean login = ConfigMySQL.login(username,password);
            out = response.getWriter();
            if(login){
                out.println("{\"login\": true}");
            }
            else{
                out.println("{\"login\": false}");
            }
        } catch (Exception e){
            out.println("{\"login\": false}");
        }

    }
}
